#!/usr/bin/env python
# -*- coding: utf-8 -*-

from web.manager.log_manager import LogManager
from web.models.stock_info import StockInfo
from web.service.base_service import BaseService

Logger = LogManager.get_logger(__name__)

"""
StockIndex的service类
"""


class StockInfoService(BaseService):

    def find_by_name(self, name: str) -> StockInfo:
        """
        根据name查询记录
        """

        return self.stock_info_dao.find_by_name(name)

    def find_by_code(self, code: str) -> StockInfo:
        """
        根据ncode查询记录
        """

        return self.stock_info_dao.find_by_code(code)

    def find_all(self) -> list:
        """
        查询所有记录
        """

        return self.stock_info_dao.find_all()

    def update_name_by_code(self, code: str, name: str):
        """
        根据code，更新name
        """

        self.stock_info_dao.update_name_by_code(code, name)
